package main

import (
	"flag"
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"os"
	"react-blog-server/app/dao"
	"react-blog-server/config"
	"react-blog-server/router"
)

func main() {
	fmt.Println("-----------------")
	fmt.Println(os.Args)
	fmt.Println("-----------------")

	// 解析命令行选项
	flag.Parse()

	gin.SetMode(gin.ReleaseMode)

	cfg, err := config.Parse()
	if err != nil {
		log.Fatalf("Failed to parse config: %v", err)
	}

	dao.InitSqlite(cfg)

	r := router.InitRouter(cfg)
	err = r.Run(":8090")
	if err != nil {
		log.Fatalf("start server failed: %v", err)
	}
}
